<?php defined('SYSPATH') or die('No direct script access.');

class Page_Controller extends PublicController {

    public function __construct() {
        parent::__construct();
    }

    /**
     * Default action method.
     */
    public function index() {
        $formData = array();
        // HTTPS Certificate is issued for joga.cz not for www.joga.cz. So to avoid 'invalid certificate' warning, change the host name.
        if ($_SERVER['SERVER_NAME'] != 'localhost' && $_SERVER['SERVER_NAME'] != '192.168.1.2' && $_SERVER['SERVER_NAME'] != 'joga.cz') {
            header('Location: https://joga.cz/seminar/');
            exit();
        }
        $this->viewData['formData'] = $formData;
        
        if (Kohana::config('yosemin.maintenenceMode')) {
        	$this->renderSubview('maintenence');
        }
        else {
        	$this->renderSubview('welcome');
        }
    }

    public function unauthorized() {
        $this->msg->info('public.unauthorizedRequest-info');
        $this->redirect('/page');
    }
    
    public function texts() {
    	$english = <<<EOD
    	
EOD;

    	$files = Kohana::find_file('i18n', 'cs_CZ/t');
    	foreach ($files as $file) {
    		include $file;
    	}
    	echo '<html><body><pre>';
    	
    	$translation = preg_split('/\\n/', $english);
    	$result = array_combine(array_keys($lang), $translation);
    	// debug::dump($result);
    	
    	foreach ($result as $key => $value) {
    		echo "\t'$key'\t\t=> '" . str_replace("'", "\'", trim($value))  . "',\n";    	
    	}
    	echo '</pre></body></html>';
    	exit();
    }
}
